﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WoWTCG
{
    public partial class DeckEditor : Form
    {
        private CardLibrary _cl;

        public DeckEditor(CardLibrary cl)
        {
            InitializeComponent();

            _cl = cl;
            comboSetFilter.Items.AddRange(_cl.SetList);
            UpdateCardListView();
        }

        private void UpdateCardListView()
        {
            foreach (Card c in _cl.Cards)
            {
                ListViewItem lvi = new ListViewItem(c.AsArray());
                lvi.Tag = c;
                lvCards.Items.Add(lvi);
            }
        }

        private void cbSetFilter_CheckedChanged(object sender, EventArgs e)
        {
            comboSetFilter.Enabled = !comboSetFilter.Enabled;
        }

        private void lvCards_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = lvCards.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y));
            ListViewItem lvi = lvCards.GetItemAt(p.X, p.Y);
            if (lvi != null)
            {
                Card c = (Card)lvi.Tag;
                pbCardPreview.Image = c.Image;
            }
        }

        private void lvCards_DoubleClick(object sender, EventArgs e)
        {
            foreach (ListViewItem lvi in lvCards.SelectedItems)
                lvDeck.Items.Add((ListViewItem)lvi.Clone());
        }
    }
}
